package com.itheima.health.dao;

import com.github.pagehelper.Page;
import com.itheima.health.pojo.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 分页查询
     * @param queryString
     * @return
     */
    Page<Setmeal> select(String queryString);

    /**
     * 新增
     * @param setmeal
     * @return
     */
    Integer insert(Setmeal setmeal);

    /**
     * 插入关系表
     * @param setmealId
     * @param checkgroupId
     * @param name
     */
    @Insert("insert into t_setmeal_group (setmealId,groupId,groupName) values (#{setmealId},#{checkgroupId},#{name})")
    void insertSetmealGroup(Integer setmealId, Integer checkgroupId, String name);

    /**
     * 查询所有
     * @return
     */
    @Select("select * from t_setmeal")
    List<Setmeal> selectAll();

    /**
     * 通过id查询
     * @param id
     * @return
     */
    @Select("select * from t_setmeal where id = #{id}")
    Setmeal findById(Integer id);

    /**
     * 获取检查组id
     * @param id
     * @return
     */
    @Select("select groupId from t_setmeal_group where setmealId = #{id}")
    List<Integer> getGroupId(Integer id);
}
